using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Entities;
using Bll;
public partial class EditPersonalInformation : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        IsDealerPage = true;
        IsMemberPage = true;
        if (!IsPostBack)
        {
            if (HttpContext.Current.Session["Login"] != null)
            {
                ArrayList arr = (ArrayList)HttpContext.Current.Session["Login"];
                CustomerBll custBll = new CustomerBll();

                CustomerInfo cust = custBll.GetByUserName(arr[0].ToString());
                lblFirstName.Text = cust.FirstName;
                lblLastName.Text = cust.LastName;
                txtAddress.Text = cust.Address;
                txtCity.Text = cust.City;
                txtPhone.Text = cust.Phone;
                txtEmail.Text = cust.Email;
                lblDateOfBirth.Text = cust.DateOfBirth.ToString();
                txtBankName.Text = cust.BankName;
                txtAccountNumber.Text = cust.AccountNumber;
                txtTaxCode.Text = cust.TaxCode;

            }
            else
            {
                Response.Redirect("home.aspx");
            }
        }

    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("home.aspx");
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        ArrayList arr = (ArrayList)HttpContext.Current.Session["Login"];
        CustomerBll custBll = new CustomerBll();

        CustomerInfo cust = new CustomerInfo();
        cust.Email = txtEmail.Text;
        cust.Address = txtAddress.Text;
        cust.Phone = txtPhone.Text;
        cust.City = txtCity.Text;
        cust.BankName = txtBankName.Text;
        cust.AccountNumber = txtAccountNumber.Text;
        cust.TaxCode = txtTaxCode.Text;
        cust.UserName = arr[0].ToString();

        if (custBll.Update(cust))
        {
            Response.Redirect("MyAccount.aspx");
        }
        else
            Response.Redirect("TestLogin2.aspx");
    }
}
